/********************************************************************************
* @file    app_key.h
* @author  jianqiang.xue
* @version V1.0.0
* @date    2021-04-03
* @brief   按键扫描
********************************************************************************/

#ifndef __APP_KEY_H
#define __APP_KEY_H

/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include <stdbool.h>

/* Publib Includes -----------------------------------------------------------*/
#include "bsp_key.h"

/* Publib Typedef ------------------------------------------------------------*/
typedef void(*bsp_key_callback)(void);

/* Publib Enum ---------------------------------------------------------------*/

typedef enum {
    KEY_EVENT_NULL = 0,
    KEY_EVENT_RELEASE,
    KEY_EVENT_PRESS,
    KEY_EVENT_TWO_PRESS,
    KEY_EVENT_SINGLE_CLICK,
    KEY_EVENT_DOUBLE_CLICK,
    KEY_EVENT_LONG_PRESS,
    KEY_EVENT_LONG_LONG_PRESS,
} key_event_t;

/* Publib Struct -------------------------------------------------------------*/

typedef struct {
    uint8_t          key_ch;
    key_event_t      event;
    bsp_key_callback callback;
} key_fun_callback_t;

/* Publib Function Prototypes ------------------------------------------------*/

bool app_key_init(void);
bool app_key_scan_start(void);
bool app_key_scan_stop(void);

#endif
